Page({
  data: {
    visitorList: [],
  },
  onShow() {
    this.getVisitorList()
  },

  async getVisitorList() {
    const {
      code,
      data: { rows: visitorList },
    } = await wx.http.get('/visitor', { current: 1, pageSize: 20 })
    if (code !== 10000) return wx.utils.toast('获取访客信息失败')
    this.setData({
      visitorList,
    })
  },

  goPassport(ev) {
    const { id, status } = ev.mark
    // 失效
    if (status === 0) {
      return wx.utils.toast('当前访问已经失效, 请重新创建')
    }
    wx.navigateTo({
      url: `/visitor_pkg/pages/passport/index?id=${id}`,
    })
  },
})
